package com.mofang.ticketing.common.core.enums.product;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Optional;

/**
 * @Author: jiangc
 * @CreateTime: 2023-03-14  13:30
 * @Version: 1.0
 */
@AllArgsConstructor
@Getter
public enum ProductCatalogEnum {

    TICKET(1, "门票", "ET", "product:ticket"),
    TICKET_TEAM(2, "团票", "GT", "product:ticket_team"),
    ;

    private Integer key;
    private String value;
    private String prefix;
    private String noKey;

    public static ProductCatalogEnum getProductCatalogEnum(Integer key) {
        if (!Optional.ofNullable(key).isPresent()) {
            return null;
        }
        for (ProductCatalogEnum catalogEnum : ProductCatalogEnum.values()) {
            if (catalogEnum.getKey().equals(key)) {
                return catalogEnum;
            }
        }
        return null;
    }

}
